cmake_minimum_required(VERSION 3.16)

set(OS_TYPE ${CMAKE_HOST_SYSTEM_NAME})
# 判断操作系统类型
if(APPLE)
    message("桌面环境：MAC OS")
elseif(WIN32)
    message("桌面环境：Windows")
elseif(UNIX)
    execute_process(
            COMMAND bash -c "echo $XDG_SESSION_TYPE"
            OUTPUT_VARIABLE SESSION_TYPE
            )

    # 判断是否包含 X11
    if(SESSION_TYPE MATCHES "x11")
        add_definitions(-D_DE_ENV_X11_)
    elseif(QT_CONFIG MATCHES "wayland")
        add_definitions(-D_DE_ENV_WAYLAND_)
    else()
        message("当前Unix")
    endif()
    message("桌面环境：${OS_TYPE} ${SESSION_TYPE}")
endif()